package service;

import model.User;
import java.util.ArrayList;
import java.util.List;

public class UserService {
    private List<User> userList = new ArrayList<>();

    public UserService() {
        // 模拟用户数据（实际可连数据库）
        userList.add(new User(1, "admin", "admin", "admin"));
        userList.add(new User(2, "user1", "123", "user"));
    }

    // 登录验证
    public User login(String username, String password) {
        for (User user : userList) {
            if (user.getUsername().equals(username) && user.getPassword().equals(password)) {
                return user;
            }
        }
        return null;
    }

    // 管理员专属：获取所有用户
    public List<User> getAllUsers() {
        return userList;
    }
}